
#file-cache C:\Inetpub\wwwroot\other\swfupload\FlashDevelop\Flash9\SWFUpload.as
package{import flash.display.Stage;import flash.display.Sprite;import flash.net.FileReferenceList;import flash.net.FileReference;import flash.net.FileFilter;import flash.net.URLRequest;import flash.net.URLRequestMethod;import flash.net.URLVariables;import flash.events.*;import flash.external.ExternalInterface;import flash.system.Security;import FileItem;import ExternalCall;/**
* Todo:
	* I should look in to using array.splice to remove cancelled files from the array.
	* Add GetFile(file_id) function that returns the FileItem js object for any file (defaults to current or first in queue).
	*
*/
public class SWFUpload extends Sprite{private const build_number : String;private var fileBrowserMany : FileReferenceList;private var fileBrowserOne : FileReference;private var file_queue : Array;private var current_file_item : FileItem;private var file_index : Array;private var successful_uploads : Number;private var queue_errors : Number;private var upload_errors : Number;private var upload_cancelled : Number;private var queued_uploads : Number;private var valid_file_extensions : Array;private var flashReady_Callback : String;private var fileDialogStart_Callback : String;private var fileQueued_Callback : String;private var fileQueueError_Callback : String;private var fileDialogComplete_Callback : String;private var uploadStart_Callback : String;private var uploadProgress_Callback : String;private var uploadError_Callback : String;private var uploadSuccess_Callback : String;private var uploadComplete_Callback : String;private var debug_Callback : String;private var movieName : String;private var uploadURL : String;private var filePostName : String;private var uploadPostObject : Object;private var fileTypes : String;private var fileTypesDescription : String;private var fileSizeLimit : Number;private var fileUploadLimit : Number;private var fileQueueLimit : Number;private var useQueryString : Boolean;private var requeueOnError : Boolean;private var debugEnabled : Boolean;private var credentials_name : String;private var credentials_password : String;private var SIZE_TOO_BIG : Number;private var SIZE_ZERO_BYTE : Number;private var SIZE_OK : Number;private var ERROR_CODE_QUEUE_LIMIT_EXCEEDED : Number;private var ERROR_CODE_FILE_EXCEEDS_SIZE_LIMIT : Number;private var ERROR_CODE_ZERO_BYTE_FILE : Number;private var ERROR_CODE_INVALID_FILETYPE : Number;private var ERROR_CODE_HTTP_ERROR : Number;private var ERROR_CODE_MISSING_UPLOAD_URL : Number;private var ERROR_CODE_IO_ERROR : Number;private var ERROR_CODE_SECURITY_ERROR : Number;private var ERROR_CODE_UPLOAD_LIMIT_EXCEEDED : Number;private var ERROR_CODE_UPLOAD_FAILED : Number;private var ERROR_CODE_SPECIFIED_FILE_ID_NOT_FOUND : Number;private var ERROR_CODE_FILE_VALIDATION_FAILED : Number;private var ERROR_CODE_FILE_CANCELLED : Number;private var ERROR_CODE_UPLOAD_STOPPED : Number;public static function main () : void;public function SWFUpload ();/**
*
		* FileReference Event Handlers
		* *
*/
private function DialogCancelled_Handler (event:Event) : void;private function Open_Handler (event:Event) : void;private function FileProgress_Handler (event:ProgressEvent) : void;private function ServerData_Handler (event:DataEvent) : void;private function HTTPError_Handler (event:HTTPStatusEvent) : void;private function IOError_Handler (event:IOErrorEvent) : void;private function SecurityError_Handler (event:SecurityErrorEvent) : void;private function Select_Many_Handler (event:Event) : void;private function Select_One_Handler (event:Event) : void;private function Select_Handler (file_reference_list:Array) : void;/**
*
			Externally exposed functions
		*
*/
private function SelectFile () : void;private function SelectFiles () : void;private function StopUpload () : void;/**
Cancels the upload specified by file_id
		 * If the file is currently uploading it is cancelled and the uploadComplete
		 * event gets called.
		 * If the file is not currently uploading then only the uploadCancelled event is fired.
		 *
*/
private function CancelUpload (file_id:String) : void;/**
This won't be used until Flex 3 comes out.
		private function SetCredentials(name:String, password:String):void {
			this.credentials_name = name;
			this.credentials_password = password;
		}
*/
private function GetStats () : Object;private function SetStats (stats:Object) : void;private function GetFile (file_id:String) : Object;private function GetFileByIndex (index:Number) : Object;private function AddFileParam (file_id:String, name:String, value:String) : Boolean;private function RemoveFileParam (file_id:String, name:String) : Boolean;private function SetUploadURL (url:String) : void;private function SetPostParams (post_object:Object) : void;private function SetFileTypes (types:String, description:String) : void;private function SetFileSizeLimit (size:String) : void;private function SetFileUploadLimit (file_upload_limit:Number) : void;private function SetFileQueueLimit (file_queue_limit:Number) : void;private function SetFilePostName (file_post_name:String) : void;private function SetUseQueryString (use_query_string:Boolean) : void;private function SetRequeueOnError (requeue_on_error:Boolean) : void;private function SetDebugEnabled (debug_enabled:Boolean) : void;/**
*
			File processing and handling functions
		*
*/
private function StartUpload (file_id:String = "") : void;private function ReturnUploadStart (start_upload:Boolean) : void;private function UploadComplete (eligible_for_requeue:Boolean) : void;/**
*
			Utility Functions
		*
*/
private function CheckFileSize (file_item:FileItem) : Number;private function CheckFileType (file_item:FileItem) : Boolean;private function BuildRequest () : URLRequest;private function Debug (msg:String) : void;private function PrintDebugInfo () : void;private function FindIndexInFileQueue (file_id:String) : Number;private function FindFileInFileIndex (file_id:String) : FileItem;private function LoadFileExensions (filetypes:String) : void;private function loadPostParams (param_string:String) : void;private function removeFileReferenceEventListeners (file_item:FileItem) : void;}}
#file-cache C:\Inetpub\wwwroot\other\swfupload\FlashDevelop\Flash9\ExternalCall.as
package{import flash.external.ExternalInterface;internal class ExternalCall{/**
public function ExternalCall()
		{

		}
*/
public static function Simple (callback:String) : void;public static function FileQueued (callback:String, file_object:Object) : void;public static function FileQueueError (callback:String, error_code:Number, file_object:Object, message:String) : void;public static function FileDialogComplete (callback:String, num_files_selected:Number, num_files_queued:Number) : void;public static function UploadStart (callback:String, file_object:Object) : void;public static function UploadProgress (callback:String, file_object:Object, bytes_loaded:uint, bytes_total:uint) : void;public static function UploadSuccess (callback:String, file_object:Object, server_data:String) : void;public static function UploadError (callback:String, error_code:Number, file_object:Object, message:String) : void;public static function UploadComplete (callback:String, file_object:Object) : void;public static function Debug (callback:String, message:String) : void;/**
Escapes all the backslashes which are not translated correctly in the Flash -> JavaScript Interface
		 * 
		 * These functions had to be developed because the ExternalInterface has a bug that simply places the
		 * value a string in quotes (except for a " which is escaped) in a JavaScript string literal which
		 * is executed by the browser.  These often results in improperly escaped string literals if your
		 * input string has any backslash characters. For example the string:
		 * 		"c:\Program Files\uploadtools\"
		 * is placed in a string literal (with quotes escaped) and becomes:
		 * 		var __flash__temp = "\"c:\Program Files\uploadtools\\"";
		 * This statement will cause errors when executed by the JavaScript interpreter:
		 * 	1) The first \" is succesfully transformed to a "
		 *  2) \P is translated to P and the \ is lost
		 *  3) \u is interpreted as a unicode character and causes an error in IE
		 *  4) \\ is translated to \
		 *  5) leaving an unescaped " which causes an error
		 * 
		 * I fixed this by escaping \ characters in all outgoing strings.  The above escaped string becomes:
		 * 		var __flash__temp = "\"c:\\Program Files\\uploadtools\\\"";
		 * which contains the correct string literal.
		 * 
		 * Note: The "var __flash__temp = " portion of the example is part of the ExternalInterface not part of
		 * my escaping routine.
*/
private static function EscapeMessage (message:*) : *;private static function EscapeString (message:String) : String;private static function EscapeArray (message_array:Array) : Array;private static function EscapeObject (message_obj:Object) : Object;}}
#file-cache C:\Inetpub\wwwroot\other\swfupload\FlashDevelop\Flash9\FileItem.as
package{import flash.net.FileReference;internal class FileItem{private static var file_id_sequence : Number;private var postObject : Object;public var file_reference : FileReference;public var id : String;public var index : Number;public var file_status : int;private var js_object : Object;public static var FILE_STATUS_QUEUED : int;public static var FILE_STATUS_IN_PROGRESS : int;public static var FILE_STATUS_ERROR : int;public static var FILE_STATUS_SUCCESS : int;public static var FILE_STATUS_CANCELLED : int;public static var FILE_STATUS_NEW : int;public function FileItem (file_reference:FileReference, control_id:String, index:Number);public function AddParam (name:String, value:String) : void;public function RemoveParam (name:String) : void;public function GetPostObject (escape:Boolean = false) : Object;public function ToJavaScriptObject () : Object;public function toString () : String;/**
// The purpose of this function is to escape the property names so when Flash
		// passes them back to javascript they can be interpretted correctly.
		// *They have to be unescaped again by JavaScript.*
		//
		// This works around a bug where Flash sends objects this way:
		//		object.parametername = "value";
		// instead of
		//		object["parametername"] = "value";
		// This can be a problem if the parameter name has characters that are not
		// allowed in JavaScript identifiers:
		// 		object.parameter.name! = "value";
		// does not work but,
		//		object["parameter.name!"] = "value";
		// would have worked.
*/
public static function EscapeParamName (name:String) : String;public static function EscapeCharacter () : String;}}